<!DOCTYPE html>
<html>

<head>

</head>

<body>

    <div id="app">
        <button @click = "upPage">上一页</button>
        <div>
            <img :src="list[index]">
        </div>
        <button @click = "downPage">下一页</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                index : 0,
                list: [
                    './img/1.png',
                    './img/2.png',
                    './img/3.png',
                    './img/4.png'
                ]
            },
            methods:{
                upPage() {
                    this.index = (this.index + 1) % this.list.length;
                },
                downPage() {
                    this.index = (this.index - 1 + this.list.length) % this.list.length;
                },
            }
        })

    </script>

</body>


</html>